
from sqlalchemy.orm import sessionmaker,declarative_base
from sqlalchemy.ext.asyncio import AsyncSession,create_async_engine

# 注意替换为你的数据库配置
DATABASE_URL = "mysql+aiomysql://root:123456@127.0.0.1/database"
engine = create_async_engine(DATABASE_URL,echo=True)
Base = declarative_base()
async_session = sessionmaker(engine, expire_on_commit=False, class_=AsyncSession)
async def get_db():
    #
    async with async_session() as session:
        yield session

